# 作者：SP
# 开发时间：2025/3/17 23:29
import sys
from PyQt5.QtWidgets import *

class MyWinDlg(QDialog):
    def __init__(self):
        super().__init__()
        self.resize(1000,500)
        self.setWindowTitle('嘻嘻嘻')
        self.initUI()
    def initUI(self):
        layout = QVBoxLayout()
        button1 = QPushButton('按钮1')
        button2 = QPushButton('按钮2')
        button3 = QPushButton('按钮3')
        self.textLine1 = QTextEdit('你好')
        layout.addWidget(button1)
        layout.addWidget(button2)
        layout.addWidget(button3)
        layout.addWidget(self.textLine1)
        self.setLayout(layout)
        #添加信号与槽的绑定
        button1.clicked.connect(self.myclick)
        button2.clicked.connect(self.myclick)
        button3.clicked.connect(self.close)
    def myclick(self):
        #返回的是信号来源的对象
        button = self.sender()
        print(button.text())
        self.textLine1.setText('你点击了'+button.text())
if __name__ == '__main__':
    app = QApplication(sys.argv)
    mywindow = MyWinDlg()
    mywindow.show()
    sys.exit(app.exec_())
